package org.wattdepot.cli.processor;

import java.util.List;
import org.wattdepot.cli.command.WattSensorDataDay;

/**
 * Parses the dailysensordata command.
 * 
 * @author Kendyll Doi
 * @author Kimberly Heu
 *
 */
public class DailySensorDataCommand extends CommandLineInterface implements WattDepotCliCommand {

  /**
   * Parses the dailysensordata command.
   * 
   * @param args The arguments of the user's command
   * @return The string containing the answer from executing the command.
   */
  public String doCommand(List<String> args) {
   StringBuffer buf = new StringBuffer(2000); // Hold the value to be returned
   String output = ""; // Value to be returned
   
   // Ensure there is the correct number of arguments
   if (args.size() == 4) {
     // Ensure there is a correct format
     if (args.get(2).equalsIgnoreCase("day")) {
       // If both are fine, then call the appropriate method
       buf.append(WattSensorDataDay.wattSensorDataDay(args.get(1), args.get(3), client));
     }
     else {
       // There was an incorrect syntax on the command
       buf.append("Incorrect syntax for dailysensordata command");
     }
   }
   else {
     // Incorrect number of arguments
     buf.append("Incorrect number of arguments for dailysensordata command");
   }
   
   // Convert the output to a string and return
   output = buf.toString();
   return output;
 }
}
